package adapter.messge_adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.itboye.hutoubenjg.R;

import java.util.List;

import base.MyApplcation;
import bean.messge_bean.SystemMessgeBean;
import util.utls.TimeFormat;

/**
 * Created by itboye on 2016/12/10.
 */

public class SystemMeesgeAdapter extends BaseAdapter {
    List<SystemMessgeBean.ListEntity> beans;
    Context context;
    public  SystemMeesgeAdapter(   List<SystemMessgeBean.ListEntity>  beans,Context context){
        this.beans=beans;
        this.context=context;
    }
    @Override
    public int getCount() {
        return beans.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHoudr houdr;
        if (convertView == null) {
            houdr = new ViewHoudr();
            convertView = LayoutInflater.from(MyApplcation.ctx).inflate(R.layout.item_messge, null);
            houdr.MessgeName = (TextView) convertView.findViewById(R.id.tvmeesgeTitlte);
            houdr.MessgeTitle = (TextView) convertView.findViewById(R.id.remessge);
            houdr.tvMessgeTime = (TextView) convertView.findViewById(R.id.tvTimeS);
            convertView.setTag(houdr);
        } else {
            houdr = (ViewHoudr) convertView.getTag();
        }
        houdr.MessgeName.setText(beans.get(position).getTitle());
        houdr.MessgeTitle.setText(beans.get(position).getSummary());
        houdr.tvMessgeTime.setText(TimeFormat.DateFormat(beans.get(position).getCreate_time()));

        return convertView;
    }

    private class ViewHoudr {
        private TextView MessgeTitle;
        private TextView MessgeName;
        private TextView tvMessgeTime;
    }
}
